from report.IHRMlogin import IhrmLogin
from common.assertTools import common_assert
class TestIhrmLogin(object):


    def setup_class(self):
        self.ihrm = IhrmLogin()
    def test_login_success(self):

        req_data = {"mobile": "13800000002", "password": "123456"}
        resp =self.ihrm.ihrmlogin_succses(req_data)
        print('登录结果:',resp.json())

        # 断言
        common_assert(resp,200,True,10000,"成功" )
        # 调用封装通用断言的函数 传参是预期结果的参数
        # assert 200==resp.status_code
        # assert True is resp.json().get("success")
        # assert 10000 == resp.json().get("code")
        # assert "成功" in resp.json().get("message")


    def test01_login_mobile_err(self):

        req_data = {"mobile": "13815260002", "password": "123456"}
        resp =self.ihrm.ihrmlogin_succses(req_data)
        print('手机号未注册:',resp.json())

        common_assert(resp,200,False,20001,"用户名或密码错误")
        # assert 200 == resp.status_code
        # assert False is resp.json().get("success")
        # assert 20001 == resp.json().get("code")
        # assert "用户名或密码错误" in resp.json().get("message")
    #
    # 断言

    #
    def test02_login_pwd_err(self):
        # ihrm=IhrmLogin()
        req_data = {"mobile": "13800000002", "password": "12345678"}
        resp =self.ihrm.ihrmlogin_succses(req_data)
        print('密码错误:',resp.json())

        common_assert(resp, 200, False, 20001, "用户名或密码错误")
        # assert 200 == resp.status_code
        # assert False is resp.json().get("success")
        # assert 20001 == resp.json().get("code")
        # assert "用户名或密码错误" in resp.json().get("message")


    def test03_10_mobile(self):
        req_data = {"mobile": "1380000000", "password": "12345678"}
        resp = self.ihrm.ihrmlogin_succses(req_data)
        print('10位手机号码:', resp.json())

        common_assert(resp, 200, False, 20001, "用户名或密码错误")
        # assert 200 == resp.status_code
        # assert False is resp.json().get("success")
        # assert 20001 == resp.json().get("code")
        # assert "用户名或密码错误" in resp.json().get("message")

    def test04_no_params(self):
        resp=self.ihrm.ihrmlogin_succses(None)
        print("无参：",resp.json())

        common_assert(resp, 200, False, 99999, "系统繁忙")

    def test04_err(self):
        req_data = {"mobile": "13800000002", "password": "123ABC"}
        resp = self.ihrm.ihrmlogin_succses(req_data)
        print("含有特殊字符：", resp.json())
        common_assert(resp, 200, False, 20001, "用户名或密码错误")









